﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace Engine.GameClass
{
   public class BaseCharacter : Engine.GameClass.ICharacter
    {
        #region Fields
        private NOWAEngine _game;
        private int _id;
        internal int _globalId;
        private string _name;
        private float _hp;
        private float _mp;
        private int _exp;       
        private byte _level;
        private Buffs _buffs;
        private Buffs _debuffs;
        private bool init = false;
        private Vector3 _position;
        private Vector3 _direction;
        #endregion

        #region Propertes

        public Vector3 Position
        {
            get { return _position; }
        }
        public Vector3 Direction
        {
            get { return _direction; }
        }

        public int GlobalID
        {
            get { return _globalId; }
        }

        public bool Init
        {
            get
            {
                return init;
            }
        }

        public Buffs Debuffs
        {
            get { return _debuffs; }
           // set { _debuffs = value; }
        }

        public Buffs Buffs
        {
            get { return _buffs; }
            //set { _buffs = value; }
        }

        public float PrecentExp
        {
            get
            {
                Experiens exper = LevelTable.getExp(_level);
                float one = (float)exper.expNeed / 100f;
                float curprecent = (float)(_exp - exper.nowLevelExp) / one;
                return curprecent;
            }
        }

        public byte Level
        {
            get { return _level; }
        }

        public int Exp
        {
            get { return _exp; }
            
        }

        public float MP
        {
            get { return _mp; }
           // set { _mp = value; }
        }

        public float HP
        {
            get { return _hp; }
            //set { _hp = value; }
        }

        public string Name
        {
            get { return _name; }
           // set { _name = value; }
        }

        public int ID
        {
            get { return _id; }
            set { _id = value; }
        } 
        #endregion

        public BaseCharacter(NOWAEngine game,string name,int globalid)
        {
            this._game = game;
            this._name = name;
            this._globalId = globalid;
            this._hp = 100;
            this._mp = 100;
            this._buffs = new Buffs(game);
            this._debuffs = new Buffs(game);
            this.init = false;

        }
        public void setHPMP(float hp, float mp)
        {
            setHP(hp);
            setMP(mp);
        }
        public void setMP(float mp)
        {
            
            _mp = mp;
        }
        public void setHP(float hp)
        {
            _hp = hp;
            
        }
        public void setExp(int exp)
        {
            _exp = exp;
        }
        public void setLvl(byte lvl)
        {
            _level = lvl;
            Experiens e = LevelTable.getExp(_level);
            _exp = e.nowLevelExp;
        }
        public virtual void Update(Microsoft.Xna.Framework.GameTime gameTime)
        {
            _buffs.Update(gameTime);
            _debuffs.Update(gameTime);
        }
        public virtual void Initialize()
        {
            init = true;
        }
    }
}
